package com.xuexi.demos.mapper;

import com.xuexi.demos.entity.AIDetectionResult;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
@Mapper
public interface StudentMapper {
    /**
     * 批量插入检测结果
     *
     * @param results 检测结果列表
     */

    @Insert({
            "<script>",
            "INSERT INTO ai_detection_results (",
            "object_key,",
            "class_name,",
            "confidence,",
            "inference_time_ms,",
            "device,",
            "created_at",
            ") VALUES",
            "<foreach collection='results' item='item' separator=','>",
            "(",
            "#{item.objectKey},",
            "#{item.className},",
            "#{item.confidence},",
            "#{item.inferenceTimeMs},",
            "#{item.device},",
            "#{item.createdAt}",
            ")",
            "</foreach>",
            "</script>"
    })
    void batchInsert(@Param("results") List<AIDetectionResult> results);

}
